
<body>

</body>
<div class="warp">
    <!--header-->
    <!--<header class="hd">
        <a href="#123" class="r-icon only-icon">
            <i class="iconfont icon-fenxiang"></i>            
                  </a>
        <a href="#123" class="l-icon only-icon">
            <i class="iconfont icon-left1"></i>                 
        </a>
        <div class="tab-top">
            <ul>
                <li><a href="#123" class="active">商品</a></li>
                <li><a href="#123">详情</a></li>
                <li><a href="#123">参数</a></li>
            </ul>
        </div>
    </header>-->

    <!--banner-->
    <div class="ban">
        <div class="swiper-container">
            <div class="swiper-wrapper">
                <?php
                    $ads = $info['ads_img'];          
                    if(!empty($ads)){
                        foreach ($ads['img_path'] as $key => $value){     
                ?>
                <div class="swiper-slide">
                    <a href="#123">
                            <img src="<?php echo $base_path.$value;?>" alt="<?php echo $ads['img_name'][$key];?>">
                    </a>
                </div>
                <?php }}?>
            </div>
            <!-- Add Pagination -->
            <div class="swiper-pagination"></div>
        </div>


    </div>

    <div class="prod-detail-tit">
        <p class="tit">
            <?php echo $info['name'];?>
        </p>
        <p class="ms-tit">
            <?php echo $info['other_name'];?>
        </p>
        <p class="price">
            <span class="address">广东深圳</span>
            <span>¥</span><?php echo $info['price'];?> <span class="free_shipping">包邮</span>
        </p>
    </div>

    <p class="return_msg">
        <i class="iconfont icon-lingchengben"></i><?php echo isset($activity['activity_desc']) ? $activity['activity_desc'] : '';?>
    </p>

    <p class="guarantee-bar">
        <span><i class="iconfont icon-ok"></i>零元购</span>
        <span><i class="iconfont icon-ok"></i>正品保障</span>
        <span><i class="iconfont icon-ok"></i>总部发货</span>
    </p>

    <!-- <div class="line-box"></div>

    <div class="sel-sku">
        <a href="#123">
            请选择颜色分类 <i class="iconfont icon-left"></i>
        </a>
    </div>

    <div class="sel-sku-box">
        <div class="b-box-1">
            <div class="l">
                <img src="/static/dist/images/pro_2.jpg" alt="">
            </div>
            <div class="r">
                <p class="price">总价: <span>¥</span><span class="price_txt">399</span> </p>
                <p class="sku-msg">已选：<span>”黄色“</span> <span>”1件”</span></p>
            </div>
        </div>
        <div class="b-box-2">
            <p class="tit">
                颜色分类
            </p>
            <ul>
                <li class="active">黄色</li>
                <li>蓝色</li>
            </ul>
        </div>
        <div class="b-box-3">
            <ul class="num-js">
                <li class="add">-</li>
                <li class="val"><input type="text" value="1"></li>
                <li class="sub">+</li>
            </ul>
            <span class="tit">购买数量</span>

        </div>

        <div class="pd-box"></div>
        <div class="shop-ft-bar-2">
            <a href="#123" class="box-1">
            <i class="iconfont icon-icon"></i>
                购物车
                <span class="num">1</span>
            </a>
            <a href="#123" class="box-2"> 
                加入购物车
            </a>

            <a href="#123" class="box-3">
                立即购买
        </a>
        </div>
    </div>
 -->
    <div class="line-box"></div>

    <div class="tab-tit">
        <ul>
            <li>
                <a  class="active" data-val="0">
                    <span>商品详情
                        </span>
                    </a>
            </li>
            <li>
                <a  data-val="1"><span>商品参数</span></a>
            </li>
        </ul>
    </div>

    <div class="tab-cont">
        <div class="detail-box active item">
            <?php echo $info['goods_detail'];?>
        </div>
        <div class="parameter-box item">
            <?php echo $info['goods_params'];?>
        </div>
    </div>




    <div class="pd-box">
    </div>
    <div class="shop-ft-bar">
        <a href="<?php echo $base_url?>home/order/shoppingcar?goodsid=<?php echo $info['goods_id']; ?>" class="box-1 shop-car-box">
            <i class="iconfont icon-icon"></i>
                购物车
                <span class="num none">1</span>
            </a>
        <a href="#123" class="box-2 add-car">
                加入购物车
            </a>

        <a href="javascript:void(0);" class="box-3" id="buy">
                立即购买
        </a>
    </div>

    <?php if($from == 'shop_car'): ?>
    <a class="reutn-btn" href="<?php echo $base_url?>home/order/shoppingCar">
    <?php else: ?>
    <a class="reutn-btn" href="index">
    <?php endif; ?>
         <i class="iconfont icon-left1"></i>  
    </a>
</div>
<div class="maksbox">

</div>


<script src="/static/dist/js/base.js"></script>
<script src="/static/dist/js/lib/swiper.jquery.min.js"></script>
<!--<script src="/static/dist/js/lib/store.legacy.min.js"></script>-->
<script>
        // 矫正rem
        function correctrem() {
            var rem_full_width = $("<div id='rem-test' style='width:7.5rem'></div>").appendTo($('body')).width();
            var device_width = Math.min(document.documentElement.clientWidth, 640);
            if (rem_full_width !== device_width) {
                document.documentElement.style.fontSize = (device_width / 7.5) * (device_width / rem_full_width) + 'px';
            }
            $('#rem-test').remove();
        }
        correctrem();
        $(function () {
            // var cartData = store.get('cartData') || [],
			var cartData = getCookie('cartData') || [],
            itemData = {
                "id": getQueryString("goods_id"),
                "price":"<?php echo $info['price'];?>",
                "quantity":"0"
                };
            var swiperSlide = $('.swiper-container').find('.swiper-slide');
            if (swiperSlide.length > 2) {
                var swiper = new Swiper('.swiper-container', {
                    pagination: '.swiper-pagination',
                    paginationClickable: true
                });
            }
            $(".tab-tit a").hammer().bind("tap", function (ev) {
                // var tagName = ev.target.tagName && ev.target.tagName.toLocaleLowerCase()
                var $this = $(this), index = 0;
                if (!$this.hasClass("active")) {
                    $this.parents(".tab-tit").find("a").removeClass("active");
                    $this.addClass("active");
                    index = $this.data("val");
                    $(".tab-cont").find(".item").removeClass("active").eq(index).addClass("active")

                }
            });

            $(".sel-sku").hammer().bind("tap", function (ev) {
                $(".maksbox").addClass("active");
                $(".sel-sku-box").addClass("active");

            })
            $(".maksbox").hammer().bind("tap", function (ev) {
                $(".sel-sku-box").removeClass("active");
                var $this = $(this)
                setTimeout(function () {
                    $this.removeClass("active");

                }, 200)
            })




            $(".add-car").hammer().bind("tap",function(){
                var $num = $(".shop-car-box").find('.num'),num = 0, isCz = false;
                if($num.hasClass('none')){
                    $num.removeClass('none');
                    num = 1;                                        
                }else{
                    num = parseInt($num.text()) || 0;                   
                    num +=1;  
					if(num>=100){
						num = '99+'						
					}
                }   
				  $num.text(num);

                for (var i = 0;i < cartData.length; i++){                                   
                    if(cartData[i].id == getQueryString("goods_id")){
                        isCz = true;
                        if(cartData[i].quantity){     
							       
                             cartData[i].quantity = parseInt(cartData[i].quantity) + 1;
                        }else{              
                            itemData.quantity =  parseInt(cartData[i].quantity) + 1;
                            cartData[i]=itemData                                                        
                        }
                    }               
                }           
                if(!cartData.length || !isCz){
                    itemData.quantity = 1;
                    cartData.push(itemData) 
                }
                // store.set('cartData',cartData)
				// console.log("???")
				setCookie('cartData',cartData,2)
            });


            if(cartData && cartData.length!=0){
				var sum = 0;
                for (var i = 0;i < cartData.length; i++){
					
					sum += parseInt(cartData[i].quantity);
                    // if(cartData[i].id == getQueryString("goods_id")){
                    //     if(cartData[i].quantity){
                    //          $(".shop-car-box").find('.num').removeClass('none').text(cartData[i].quantity);
                    //     }
                    // }                                       
                }               
				if(sum>=100){
					sum = '99+'						
				}
				 $(".shop-car-box").find('.num').removeClass('none').text(sum);
            }

            

            function getcurrentCartData(id){
                var result = {};
                if(cartData && cartData.length!=0){
                    for (var i = 0;i < cartData.length; i++){
                        if(cartData[i].id == id){
                            result = cartData[i];
                        }                                       
                    }               
                }           
                return result;
            }

            $('#buy').on('click', function(){
                var selArr=[];
                var selObj = {};
                selObj.goods_id = <?php echo isset($goods_id) ? $goods_id : ''; ?>;                    
                selObj.quantity = 1;
                selArr.push(selObj);
                location.href = "<?php echo $base_url;?>home/order/submitorder?data=" + encodeURI(JSON.stringify(selArr)) + "&goods_id=" + selObj.goods_id;
            });
        })
        

        function getQueryString(name) { 
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
            var r = window.location.search.substr(1).match(reg); 
            if (r != null) return unescape(r[2]); return null; 
        } 

		function setCookie(cname, cvalue, exdays) {
			cvalue = JSON.stringify(cvalue)

			var d = new Date();
			d.setTime(d.getTime() + (exdays*60*60*1000));
			var expires = "expires="+d.toUTCString();
			document.cookie = cname + "=" + cvalue + "; " + expires + ";path=/";  
		}
        function getCookie(cname) {
			var name = cname + "=";
			var ca = document.cookie.split(';');
			for(var i=0; i<ca.length; i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1);
				if (c.indexOf(name) != -1){
					return JSON.parse(c.substring(name.length, c.length));
				} 
			}
			return "";
		}
        
</script>

</body>

</html>
